﻿package PinballCode.Screens
{
	//Imports
	//import flash.display.Sprite;
	import flash.display.Stage;
	import PinballCode.MainApp;
	import flash.events.MouseEvent;
	import flash.display.SimpleButton;
	
	
	// Main Menu Screen
	public class MainMenu extends Screen
	{		
		// Constructor
		public function MainMenu(app:MainApp)
		{
			super(app);
			init();
		}
		
		//////////////////////
		//Initialize variables
		//////////////////////////////////////////
		public function init()
		{
			this.x = 340;
			this.y = 250;
		}
		
		/////////////////////
		//Calls the super method bringIn() and sets up buttons/EventListeners etc
		///////////////////////////////////
		public override function bringIn()
		{
			// the next line calls the superclass' bringIn();
			super.bringIn();
			
			//////////////////////////////////TO BE CHANGED
			//hard coded values for the location of the scree
			
			// set up the buttons
			StartButton_mvc.addEventListener(MouseEvent.CLICK, goToGame);
			InstrButton_mvc.addEventListener(MouseEvent.CLICK, goToInstructions);
			CreditsButton_mvc.addEventListener(MouseEvent.CLICK, goToCredits);
			
			StartButton_mvc.addEventListener(MouseEvent.MOUSE_OVER, enlarge);
		}
		
		
		// Transition to Game Screen
		private function goToGame(e:MouseEvent)
		{
			// tell the Document class to display the Game screen
			removeFromScreen();
			app.displayScreen(Game);
		}
		
		// Transition to Instructions Screen
		private function goToInstructions(e:MouseEvent)
		{
			removeFromScreen();
			app.displayScreen(InstructionsScreen);
		}
		
		// Transition to Credits Screen
		private function goToCredits(e:MouseEvent)
		{
			removeFromScreen();
			app.displayScreen(CreditScreen);
		}
		
		// Makes the object bigger
		public function enlarge(e:MouseEvent)
		{
			e.target.size *=1.1;
		}
		
		// Removes listeners when this screen is removed
		public function removeFromScreen():void {
			StartButton_mvc.removeEventListener(MouseEvent.CLICK, goToGame);
			InstrButton_mvc.removeEventListener(MouseEvent.CLICK, goToInstructions);
			CreditsButton_mvc.removeEventListener(MouseEvent.CLICK, goToCredits);
			
			StartButton_mvc.removeEventListener(MouseEvent.MOUSE_OVER, enlarge);
		}
		
		// Removes screen from MainApps
		public override function cleanUp()
		{
			// removeEventListener for the play_btn
			//start_btn.removeEventListener(MouseEvent.CLICK, goToGame);
			// call the superclass' cleanUp();
			super.cleanUp();
		}
		
	}
}